#include <iostream>
#include <memory>
#include "listener.hpp"
#include "reactor.hpp"
#include "epoller.hpp"
#include "PackageParse.hpp"
#include "IOserverce.hpp"

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: ./server port" << std::endl;
        return 0;
    }
    uint16_t port = std::stoi(argv[1]);
    IOserverce io(PackageParse::Parse);
    Listener listener(port,io);
    std::unique_ptr<Reactor> ptr = std::make_unique<Reactor>();
    ptr->AddConnection(listener.SockFd(), EPOLLIN | EPOLLET, std::bind(&Listener::Accepter, &listener, std::placeholders::_1), nullptr, nullptr);
    ptr->Dispatcher();
    return 0;
}